HW 10 - Interrupt Management
Title Banner


Technical Q&A's


HW 10 - Interrupt Management (15-July-95)


Q I am having trouble with Interrupt Management in my native ndrv. I can get it to work once using the GetInterruptFunctions() and InstallInterruptFunctions() calls, but I can't undo this Interrupt install/enable sequence so that I can turn them on again later. In fact, it crashes the second time I use the install/enable sequence. Do I need to handle the default enabler and/or disabler differently in order to make the process repeatable?

A The code sample below shows how to handle interrupt installation:

//===================================================================
//
// GraphicsOSSInstallVBLInterrupts()
//	This routine is specific for VBL interrupts and assumes that a driver's 'driver-ist' only
//	pertains to VBL's. The Video Services Library (VSL) kHBLService and kFrameService are ignored.
//	Interrogate the HAL to get the interrupt handler, the interrupt enabler, the interrupt disabler,
//	and the VBL 'refCon' (private HAL data that the HAL might need to carry out the functions).
//	This version of GDX interrupt handling isolates the HAL from knowing stuff about how //  the handlers are installed. Conventions interrupt routines must follow:
//		interrupt handler:	clear the hw interrupt source
//		interrupt enabler:	enable the hw interrupt source
//		interrupt disabler:	disable the hw interrupt source and :
//		return true if interrupts were enabled 	before the call
//		return false if interrupts were disabled before the call
//								
//	
//			->	regEntryID		Name Registry RegEntryID that should have the propertyName
//								
//=====================================================================================================
GDXErr GraphicsOSSInstallVBLInterrupts(RegEntryID *regEntryID)
{
	
	Boolean installVBLInterrupts = false; // Ask HAL if OSS should install VBL routines
	InterruptEnabler enabler = NULL; // Use default enabler if HAL's enabler is NULL
	InterruptDisabler disabler = NULL; // Use default disabler if HAL's disabler is NULL
	
	OSSData *ossData = GraphicsOSSGetOSSData();
	
	GDXErr err = kGDXErrUnknownError; // Assume failure
	
	
	err = GraphicsHALGetVBLInterruptRoutines(&installVBLInterrupts, &ossData->chainDefault,
			&ossData->halVBLHandler, &ossData->halVBLEnabler, &ossData->halVBLDisabler,
			&ossData->vblRefCon);
	
	if (err)
		goto ErrorExit;
		
	if (installVBLInterrupts)// The OSS should handle the HAL's vbl interrupts
	{
	// It is possible that OSS should install the routines but doesn't have the InterruptSetMember if (ossData->hasInterruptSetMember)
		{
			InterruptServiceIDType vslServiceID;
			OSStatus osStatusErr;
			OSErr osErr;
			
			osStatusErr = GetInterruptFunctions(ossData->interruptSetMember.setID,
					ossData->interruptSetMember.member,
					&ossData->defaultRefCon,
					&ossData->defaultVBLHandler,
					&ossData->defaultVBLEnabler,
					&ossData->defaultVBLDisabler );
					
			if (osStatusErr)
			{
				err = kGDXErrOSSNoDefaultVBLRoutines;
				goto ErrorExit;
			}

// If the HAL's enabler/disabler functions are NULL, that indicates that the HAL
// can use the default enabler/disabler function. Otherwise, the OSS enabler/disabler functions will be installed.
// NOTE: Making a call to InstallInterruptFunctions() with NULL as the enabler/disabler, than the enablers currently installed (the 'default enablers') are used.
			
			if (NULL != ossData->halVBLEnabler)
				enabler = GraphicsOSSVBLInterruptEnabler;
				
			if (NULL != ossData->halVBLDisabler)
				disabler = GraphicsOSSVBLInterruptDisabler;
				
			osStatusErr = InstallInterruptFunctions(ossData->interruptSetMember.setID, 
					ossData->interruptSetMember.member, ossData->vblRefCon,
					GraphicsOSSVBLInterruptHandler, enabler, disabler);
			
			if (osStatusErr)
			{
				err = kGDXErrOSSUnableToInstallVBLRoutines;
				goto ErrorExit;
			}

			// Successfully installed the routines.
			ossData->installedHALVBLRoutines = true;
			
		} else {
			err = kGDXErrOSSNoISTProperty;
			goto ErrorExit;
		}
	
	}

ErrorExit:
	
	return err;
}

Technical Support
Technical Q&As
Previous Question | Contents | Next Question

Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help